import { Injectable } from '@angular/core';
import { NzModalService } from 'ng-zorro-antd/modal';
import { AdvancedFilterDialogComponent } from './advanced-filter-dialog.component';
import { FilterGroupDto } from '../../proxy/joy/erp/basic-archives/core/filters/models';
import { LocalizationService } from '@abp/ng.core';

export interface AdvancedFilterDialogOptions {
  width?: number;
}

@Injectable({
  providedIn: 'root'
})
export class AdvancedFilterDialogService {
  constructor(
    private modalService: NzModalService,
    private localizationService: LocalizationService
  ) {}

  show(entityConfig: any, filterGroup: FilterGroupDto, options: AdvancedFilterDialogOptions = {}) {
    const { width = 880 } = options;

    return this.modalService.create({
      nzTitle: this.l('BasicArchives::UI:AdvancedFilterDialog.Title'),
      nzContent: AdvancedFilterDialogComponent,
      nzWidth: width,
      nzFooter: null,
      nzMaskClosable: false,
      nzComponentParams: {
        entityConfig,
        filterGroup
      }
    });
  }

  protected l(key: string, ...args: any[]): string {
    return this.localizationService.instant(key, ...args);
  }
} 